package com.bsj.pay.controller.admin;

import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import com.bsj.pay.model.BalanceBean;
import com.bsj.pay.service.BalanceService;
import com.bsj.pay.util.ResultUtil;
import com.github.pagehelper.PageInfo;

@RequestMapping("/admin/balance")
@Controller("adminBalanceController")
public class BalanceController {
	@Autowired
	private BalanceService balanceService;
	
	@ResponseBody
	@RequestMapping(value = "/list.html")
	public Map list(HttpServletRequest req, HttpServletResponse res,int page,int limit,BalanceBean balance) {
		BalanceBean queryModel=new BalanceBean();
		if(balance.getUser_id()!=null)queryModel.setUser_id(balance.getUser_id());
		if(balance.getType()!=null)queryModel.setType(balance.getType());
		if(!StringUtils.isEmpty(balance.getTimeStr()))queryModel.setTimeStr(balance.getTimeStr());
		if(!StringUtils.isEmpty(balance.getRemarks()))queryModel.setRemarks(balance.getRemarks());
		PageInfo<BalanceBean> pageInfo=balanceService.pageList(queryModel, page, limit);
		return ResultUtil.getQuerySuccessResult(pageInfo);
	}
	
	@RequestMapping("/listPage.html")
    public ModelAndView listPage(HttpServletRequest request,HttpServletResponse response,ModelAndView mav) {
		mav.setViewName("admin/balance/list");
		return mav;
    }
}
